RingBuffer template. More...
#include <tringbuffer.h>
Public Member Functions | |
TRingBuffer (int32 n=0) | |
Default constructor. | |
TRingBuffer (T *data, int32 n) | |
construct a RingBuffer with n data objects | |
virtual | ~TRingBuffer () |
Destructor. | |
bool | setBuffer (T *data, int32 n) |
fills the buffer with n data objects | |
bool | resize (int32 n) |
resize buffer to size n | |
bool | isEmpty () const |
tells if the buffer is empty | |
int32 | countFree () const |
returns the number of free slots in the buffer | |
int32 | countFilled () const |
returns the number of items in the buffer | |
int32 | size () const |
returns the number of slots in the buffer | |
template<int32 count> | |
int32 | write (const T *data) |
write count items to buffer | |
int32 | write (const T *data, int32 count) |
write count items to buffer | |
bool | write (const T &data) |
write one item to buffer | |
int32 | read (T *data, int32 count) |
read count items from buffer | |
bool | read (T &data) |
read one item from buffer | |
const T & | peek () const |
look at current item in buffer | |
int32 | peek (T *data, int32 count) const |
look at count items in buffer | |
void | flush () |
remove all items from buffer | |
int32 | trash (int32 count) |
remove count items from buffer |
RingBuffer template.
A RingBuffer is a data structure that uses a fixed-size buffer with circular connections.
TRingBuffer | ( | int32 | n = 0 |
) | [inline] |
Default constructor.
RingBuffer constructor.
[in] | n | : initial size of the buffer |
TRingBuffer | ( | T * | data, | |
int32 | n | |||
) | [inline] |
construct a RingBuffer with n data objects
RingBuffer constructor with specified data pointer.
[in] | data | : pointer to data objects to be held in the buffer |
[in] | n | : initial size of the buffer |
~TRingBuffer | ( | ) | [inline, virtual] |
Destructor.
RingBuffer destructor.
bool setBuffer | ( | T * | data, | |
int32 | n | |||
) | [inline] |
fills the buffer with n data objects
Sets the RingBuffer to specified data pointer and given size n.
[in] | data | : pointer to data objects to be held in the buffer |
[in] | n | : size of the buffer |
bool resize | ( | int32 | n | ) | [inline] |
resize buffer to size n
Resize buffer to size n, if the buffer is the owner of the data.
[in] | n | : number of requested slots in the buffer |
bool isEmpty | ( | ) | const [inline] |
tells if the buffer is empty
Tells if the buffer is empty.
int32 countFree | ( | ) | const [inline] |
returns the number of free slots in the buffer
Returns the number of free slots in the buffer.
int32 countFilled | ( | ) | const [inline] |
returns the number of items in the buffer
Returns the number of items in the buffer.
int32 size | ( | ) | const [inline] |
returns the number of slots in the buffer
Returns the number of slots in the buffer.
int32 write | ( | const T * | data | ) | [inline] |
write count items to buffer
[in] | data | : pointer to the data structure |
[in] | count | : number of items to be written |
int32 write | ( | const T * | data, | |
int32 | count | |||
) | [inline] |
write count items to buffer
Write count items to buffer.
[in] | data | : pointer to the data structure |
[in] | count | : number of items to be written |
bool write | ( | const T & | data | ) | [inline] |
write one item to buffer
Write one item to buffer.
[in] | data | : reference to the data structure |
int32 read | ( | T * | data, | |
int32 | count | |||
) | [inline] |
read count items from buffer
[in,out] | data | : pointer to the data structure |
[in] | count | : number of requested items |
bool read | ( | T & | data | ) | [inline] |
read one item from buffer
Read one item from buffer.
[in,out] | data | : reference to the data structure |
const T & peek | ( | ) | const [inline] |
look at current item in buffer
look at current item in buffer without changing the read position
int32 peek | ( | T * | data, | |
int32 | count | |||
) | const [inline] |
look at count items in buffer
look at count items in buffer without changing the read position
[in,out] | data | : pointer to the data structure |
[in] | count | : number of requested items |
void flush | ( | ) | [inline] |
remove all items from buffer
Remove all items from buffer.
int32 trash | ( | int32 | count | ) | [inline] |
remove count items from buffer
Remove count items from buffer.
[in] | count | : number of items to be removed |